var t_skey = window.localStorage.getItem("skey") || "chomoo_test_002";
var t_uid = window.localStorage.getItem("uid") || "chomoo_test_002";
console.log(t_skey)
var t_userApi = "https://hehua.ai-zuoye.cn/users/login?skey=" + t_skey;
$.get(t_userApi, function(_res) {
	if(_res["code"] != 0) {
		location.href = "https://hehua.ai-zuoye.cn/project/?proId=lotus1912";
		return;
	}
	console.log(_res);
	var t_uid = _res["user"]["uid"];
	var t_name = _res["user"]["name"];
	var t_avatar = _res["user"]["avatar"];
	var t_skey = _res["skey"];
	
	window.localStorage.setItem("uid",t_uid);
	window.localStorage.setItem("name",t_name);
	window.localStorage.setItem("avatar",t_avatar);
	window.localStorage.setItem("skey",t_skey);
})

if(!t_skey) {
	location.href = "https://hehua.ai-zuoye.cn/project/?proId=lotus1912";
}

function getPara(_key) {
	var reg = new RegExp("(^|&)" + _key + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r != null) return unescape(r[2]);
	return null;
}

chomoo.projectid = "LotusTobacco"; //项目ID
chomoo.appid = "wxe893bfa0b4fdf4cc"; //wxe893bfa0b4fdf4cc   wx663b7bc7d5005b26
chomoo.component_appid = "wxcbca8b69f0a8770a";
chomoo.authMode = authMode.DEBUG; //授权方式，BASE隐式授权，USERINFO显示授权，DEBUG调试模式（必需手动设置openid参数）
chomoo.isComponent = true; //采用Component授权方式
chomoo.init(); //调用初始化方法
chomoo.wxJsReady(function() {
	//分享内容对象
	var shareModel = {
		imgUrl: "",
		lineLink: location.href,
		descContent: "",
		shareTitle: ""
	}
	chomoo.setShare(shareModel, function() {
		console.log("分享成功回调")
	});

	chomoo.setShareTimeline(shareModel, function() {
		console.log("分享朋友圈成功回调")
	});
});

function resetShare(_imgUrl,_lineLink,_descContent,_shareTitle) {
	var shareModel1 = {
		imgUrl: _imgUrl,
		lineLink: _lineLink,
		descContent: _descContent,
		shareTitle: _shareTitle
	}

	chomoo.setShare(shareModel1, function() {
		console.log("分享成功回调")
	});

	chomoo.setShareTimeline(shareModel1, function() {
		console.log("分享朋友圈成功回调")
	});
}